<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>分类查询用户注册</title>
<link href="<%=path%>/static/usercss/css/all.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=path%>/static/js/jquery-3.2.1.js"></script>
<!--[if IE]>
<script>
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})()
</script>
<![endif]-->



</head>
<body>
<jsp:include page="/WEB-INF/web/includ/header.jsp"></jsp:include>
<c:set value="${sessionScope.code }" var="code"></c:set>
<section>
  <div class="wrap">
    <div  id="login">
      <div class="login">
        <div class="loginForm" >
          <h1>用户登录</h1>
          
          <form action="<%=path%>/web/login" id="f1" method="post">
          <ol>
            <li>
              <label >用户名：</label>
              <input type="text" name="name" id="name" value="${sessionScope.userinfoName }">             
            </li>
            <li>
              <label >密码：</label>
              <input type="password" name="password" id="passsword">  
                          
            </li>
            
            <li>          
              <label >验证码：</label>
              <input type="text" name="validatecode" id="validatecode"  class="verifycode">
            	<img src="<%=path %>/web/setValidateCode?" width="60" height="30"><a title="更换验证码" href="javascript:void(0);" id="returnValidateCode">更换</a>
            </li>
            <li class="button" >
              <label></label>
              <input name="rememberMe" type="checkbox" class="checkbox" id="rememberMe" value="true" data-val="true" data-val-required="记住我? 字段是必需的。">
              <label for="rememberMe">记住我?</label>
              <input id="submit" type="submit"  value="登录">
            </li>
          </ol>
          </form>
          <div class="msg"><a href="<%=path %>/web/userLogin/reg.html">立即注册</a><a href="<%=path %>/web/userLogin/changeFir.html">忘记密码？</a></div>
        </div>
      </div>
    </div>
  </div>
</section>

<jsp:include page="/WEB-INF/web/includ/footer.jsp"></jsp:include>

<script type="text/javascript" src="<%=path%>/static/managecss/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="<%=path%>/static/managecss/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript">
	var msg ="${param.msg}";

	if(msg=='code'){
		
		layer.alert("验证码错误");	
	}
	if(msg=='user'){
		
		layer.alert("用户名或密码错误");
	}
</script>
<script type="text/javascript">
	var x=true;
	$(function() {
		$("#validatecode").blur(function() {
			$.get("<%=path%>/web/code",{},function(mes){
				var str1 = $(this).val();
				if(str1.toLowerCase() == mes.toLowerCase())
				{
				
					x=true;					
				}
				else{
					layer.alert("验证码错误");
					x=false;				
				}	
			}.bind(this))			
		});
		
		$("#f1").submit(function(e){
		
			  return x;
		});
		
		$("#f1").validate({
			rules:{
				name:{
						required:true,
						minlength:4,
						maxlength:16
					},
					password:{
						required:true
					},
					validatecode:{
						required:true,
						
					},
				},
				errorPlacement: function(error, element) {                             
					error.appendTo( element.parent() );                            
				},
				onkeyup:false,
				focusCleanup:true,
				success:"valid"
		});		
	});
	

	$(function() {
			$("#returnValidateCode").click(function() {
					var m = Math.random();
					$(this).prev().attr("src","<%=path %>/web/setValidateCode?id="+m)
				
			});
	});


</script>


</body>
</html>
